using MudWebApp.Requests;
using MudWebApp.Responses;
using MudWebApp.Services.Contracts;

namespace MudWebApp.Services.Implementations;

public class AccountService(HttpClient httpClient) : IAccountService
{
    public async Task<LoginResult> LoginAsync(LoginData data)
    {
        var response = await httpClient.PostAsJsonAsync("api/account/login", data);
        var result = await response.Content.ReadFromJsonAsync<LoginResult>();
        return result!;
    }

    public  async Task<RegisterResult> RegisterAsync(RegisterData data)
    {
        var response =await httpClient.PostAsJsonAsync("api/account/register", data);
        var result = await response.Content.ReadFromJsonAsync<RegisterResult>();
        return result!;
    }
}